package com.xujl.mvcbind.adapter.provider;

import com.chad.library.adapter.base.BaseBinderAdapter;
import com.xujl.mvcbind.bean.FourMultiEntity;
import com.xujl.mvcbind.bean.OneMultiEntity;
import com.xujl.mvcbind.bean.ThreeMultiEntity;
import com.xujl.mvcbind.bean.TwoMultiEntity;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DiffUtil;

public class ProviderMultiAdapter extends BaseBinderAdapter {
    public ProviderMultiAdapter (List list) {
        super(list);
        addItemBinders();
    }


    private void addItemBinders () {
        addItemBinder(OneMultiEntity.class, new OneItemBinder(), new DiffUtil.ItemCallback<OneMultiEntity>() {
            @Override
            public boolean areItemsTheSame (@NonNull OneMultiEntity oldItem, @NonNull OneMultiEntity newItem) {
                return oldItem.equals(newItem);
            }

            @Override
            public boolean areContentsTheSame (@NonNull OneMultiEntity oldItem, @NonNull OneMultiEntity newItem) {
                return newItem.equals(oldItem);
            }
        });
        addItemBinder(TwoMultiEntity.class, new TwoItemBinder(), new DiffUtil.ItemCallback<TwoMultiEntity>() {
            @Override
            public boolean areItemsTheSame (@NonNull TwoMultiEntity oldItem, @NonNull TwoMultiEntity newItem) {
                return oldItem.equals(newItem);
            }

            @Override
            public boolean areContentsTheSame (@NonNull TwoMultiEntity oldItem, @NonNull TwoMultiEntity newItem) {
                return oldItem.equals(newItem);
            }
        });
        addItemBinder(ThreeMultiEntity.class, new ThreeItemBinder(), new DiffUtil.ItemCallback<ThreeMultiEntity>() {
            @Override
            public boolean areItemsTheSame (@NonNull ThreeMultiEntity oldItem, @NonNull ThreeMultiEntity newItem) {
                return oldItem.equals(newItem);
            }

            @Override
            public boolean areContentsTheSame (@NonNull ThreeMultiEntity oldItem, @NonNull ThreeMultiEntity newItem) {
                return oldItem.equals(newItem);
            }
        });
        addItemBinder(FourMultiEntity.class, new FourItemBinder(), new DiffUtil.ItemCallback<FourMultiEntity>() {
            @Override
            public boolean areItemsTheSame (@NonNull FourMultiEntity oldItem, @NonNull FourMultiEntity newItem) {
                return oldItem.equals(newItem);
            }

            @Override
            public boolean areContentsTheSame (@NonNull FourMultiEntity oldItem, @NonNull FourMultiEntity newItem) {
                return oldItem.equals(newItem);
            }
        });
    }
}
